package com.chaosj.skill.guava.basic

import com.google.common.base.Throwables

/**
 * @Description:
 * @author: caoyangjie
 * @date: 2019年11月2019/11/27日 09:07
 * @Copyright: © 赢时胜
 */
class GuavaThrowables {
    static void main(args){
        Throwables.throwIfInstanceOf(new GuavaException(),SkillException.class)
        println("上面的异常被内部吃掉了")
        try{
            Throwables.throwIfInstanceOf(new GuavaException(),GuavaException.class)
        }catch(Exception e){
            println("异常被抛出来到了这里")
        }
        println(Throwables.getCausalChain(new GuavaException(new SkillException())))

    }

    static class GuavaException extends RuntimeException{
        GuavaException(){
        }
        GuavaException(Throwable cause) {
            super(cause)
        }
    }

    static class SkillException extends RuntimeException{

    }

    static class SkillError extends Error{

    }
}
